package com.py.korona.datasource;

import android.content.ContentResolver;
import com.py.korona.db.geo.GeoPoint;
import com.py.korona.db.geo.Screenshot;
import com.py.korona.db.model.CategoriesInRoomEntity;
import com.py.korona.db.model.CategoryEntity;
import com.py.korona.db.model.RoomEntity;

public class FakeDataInitializer {
    public void initFakeData() {
        ScreenshotDatasource screenShotDatasource = ScreenshotDatasource.getInstance();
        // init screenshot
        Screenshot screenshot = new Screenshot();
        screenshot.setFileName("belarus_grodno_korona_a.jpg");
        screenshot.addGeoPoint(new GeoPoint(53.713f, 23.814946f));
        screenshot.addGeoPoint(new GeoPoint(53.7134f, 23.8176f));
        screenshot.addGeoPoint(new GeoPoint(53.7101f, 23.819f));
        screenshot.addGeoPoint(new GeoPoint(53.7097f, 23.8163f));
        //
        screenShotDatasource.insertScreenshot(screenshot);
    }

    public static void appendRecords(ContentResolver contentResolver) throws Exception {
        RoomEntity roomEntity = new RoomEntity(contentResolver);
        roomEntity.setDescription("description of room1");
        roomEntity.setText("room1");
        roomEntity.save();
        Long roomEntity1Id = roomEntity.get_id();
        roomEntity = new RoomEntity(contentResolver);
        roomEntity.setDescription("description of room2");
        roomEntity.setText("room2");
        roomEntity.save();
        Long roomEntity2Id = roomEntity.get_id();
        roomEntity = new RoomEntity(contentResolver);
        roomEntity.setDescription("description of room3");
        roomEntity.setText("room3");
        roomEntity.save();
        Long roomEntity3Id = roomEntity.get_id();
        CategoryEntity categoryEntity = new CategoryEntity(contentResolver);
        categoryEntity.setText("category 1");
        categoryEntity.save();
        Long categoryEntityId = categoryEntity.get_id();
        CategoriesInRoomEntity categoriesInRoomEntity = new CategoriesInRoomEntity(contentResolver);
        categoriesInRoomEntity.setCategory(categoryEntityId);
        categoriesInRoomEntity.setRoom(roomEntity3Id);
        categoriesInRoomEntity.save();
        categoriesInRoomEntity = new CategoriesInRoomEntity(contentResolver);
        categoriesInRoomEntity.setCategory(categoryEntityId);
        categoriesInRoomEntity.setRoom(roomEntity2Id);
        categoriesInRoomEntity.save();
        categoriesInRoomEntity = new CategoriesInRoomEntity(contentResolver);
        categoriesInRoomEntity.setCategory(categoryEntityId);
        categoriesInRoomEntity.setRoom(roomEntity1Id);
        categoriesInRoomEntity.save();
    }
}
